﻿
<!--
    Copyright (c) 2011-2012 RaisingForce Team (Alikin Sergey)
    
    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation
    files (the "Software"), to deal in the Software without
    restriction, including without limitation the rights to use,
    copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following
    conditions:
    
    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    OTHER DEALINGS IN THE SOFTWARE.
-->
<UserControl x:Class="RaisingForce.RaiseHardwareTest.View.MainView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             d:DesignHeight="300"
             d:DesignWidth="400"
             mc:Ignorable="d">
    <Grid>
        <Grid.Resources>
            <ResourceDictionary Source="MainViewResources.xaml" />
        </Grid.Resources>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <!--  Главное меню  -->
        <Menu Grid.Row="0"
              Grid.Column="0"
              Grid.ColumnSpan="2"
              Margin="5,0"
              Background="White"
              IsMainMenu="True">

            <MenuItem Header="{Loc Main_Menu_File}">
                <MenuItem DataContext="{Binding ImportOptionsCommand}" Style="{StaticResource CommandMenuItemStyle}" />
                <MenuItem DataContext="{Binding ExportOptionsCommand}" Style="{StaticResource CommandMenuItemStyle}" />
                <Separator />
                <MenuItem Command="{Binding Window.CloseCommand}" Header="{Loc Main_Menu_Exit}" />
            </MenuItem>

            <MenuItem Header="{Loc Main_Menu_View}">
                <MenuItem Header="{Loc Main_Menu_Language}"
                          ItemContainerStyle="{StaticResource LanguageCommandMenuItemStyle}"
                          ItemsSource="{Binding LanguageSelector}" />

                <Separator />

                <MenuItem Header="{Loc Main_Menu_HideService}"
                          IsCheckable="True"
                          IsChecked="{Binding VisibilityOptions.CommandsAreHidden,
                                              Mode=TwoWay}" />
                <MenuItem Header="{Loc Main_Menu_HideHardware}"
                          IsCheckable="True"
                          IsChecked="{Binding VisibilityOptions.LabeledCommandsAreHidden,
                                              Mode=TwoWay}" />
            </MenuItem>

            <MenuItem Header="{Loc Main_Menu_Service}"
                      ItemContainerStyle="{StaticResource CommandMenuItemStyle}"
                      ItemsSource="{Binding Commands}" />

            <MenuItem Header="{Loc Main_Menu_Hardware}"
                      ItemContainerStyle="{StaticResource LabeledCommandMenuItemStyle}"
                      ItemsSource="{Binding LabeledCommands}" />

            <MenuItem Header="{Loc Main_Menu_Help}">
                <MenuItem DataContext="{Binding AboutCommand}" Style="{StaticResource CommandMenuItemStyle}" />
            </MenuItem>
        </Menu>



        <!--  Имя и описание загруженной сборки  -->
        <ContentPresenter Grid.Row="1"
                          Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Content="{Binding HardwareSelector}" />

        <WrapPanel x:Name="commandsPanel"
                   Grid.Row="2"
                   Grid.Column="0"
                   Grid.ColumnSpan="2"
                   Margin="10,0,5,0"
                   Orientation="Horizontal">

            <ItemsControl IsTabStop="False"
                          ItemsSource="{Binding Commands}"
                          ItemTemplate="{StaticResource CommandTemplate}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.Style>
                    <Style TargetType="ItemsControl">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding VisibilityOptions.CommandsAreHidden}" Value="True">
                                <Setter Property="Visibility" Value="Collapsed" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ItemsControl.Style>
            </ItemsControl>

            <DockPanel>
                <TextBlock DockPanel.Dock="Left"
                           Style="{StaticResource StatusTextStyle}"
                           Text="{Loc Main_Text_Status}" />
                <Border MinWidth="100"
                        Margin="5"
                        BorderBrush="Black"
                        BorderThickness="1"
                        CornerRadius="10">
                    <TextBlock Style="{StaticResource StatusTextStyle}" Text="{Binding StatusText}" />
                </Border>
            </DockPanel>
        </WrapPanel>

        <GroupBox Grid.Row="3"
                  Grid.Column="0"
                  Grid.ColumnSpan="2"
                  Margin="5"
                  Header="{Loc Main_LabeledCommands_GroupTitle}"
                  Padding="2">
            <GroupBox.Style>
                <Style TargetType="{x:Type GroupBox}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding VisibilityOptions.LabeledCommandsAreHidden}" Value="True">
                            <Setter Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </GroupBox.Style>
            <ScrollViewer VerticalScrollBarVisibility="Auto">
                <ItemsControl Margin="0,0,5,0"
                              IsTabStop="False"
                              ItemsSource="{Binding LabeledCommands}"
                              ItemTemplate="{StaticResource LabeledCommandTemplate}" />
            </ScrollViewer>
        </GroupBox>
    </Grid>
</UserControl>
